/*
This file as a kind of hardware abstraction layer and OS layer. This file must hold all
the common hacks to unify the rest of code
*/

//REV170:  Added to easy include some common headers
#ifndef _ZELESTE3D_CORE_ZELESTECORELIB_H_
#define _ZELESTE3D_CORE_ZELESTECORELIB_H_

// A macro to disallow the copy constructor and operator= functions
// This should be used in the private: declarations for a class
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
	TypeName(const TypeName&);             \
	void operator=(const TypeName&)

// This macro allows the use of AT macro that returns lines and file of the line in which is present the macro.
#define STRINGIFY(x) #x
#define TOSTRING(x) STRINGIFY(x)
#define AT __FILE__ ":" TOSTRING(__LINE__)


//----------------------------------------------------------------------------
// Platform-specific information.  The defines to control which platform is
// included are listed below.  Add others as needed.
//
// _WIN32 or WIN32          :  Microsoft Windows
// __APPLE__                :  Macintosh OS X
// __linux__ or __LINUX__   :  Linux
//----------------------------------------------------------------------------
// Microsoft Windows platform
//----------------------------------------------------------------------------
#if defined(_WIN32) || defined(WIN32)

	#define ZEL_PLATFORM_WIN32

	#ifdef _WIN32  
		#if !defined(WIN32)
			#define WIN32
		#endif
	#endif

	#ifdef WIN32  
		#if !defined(WIN32)
			#define _WIN32
		#endif
	#endif

	#define ZEL_LITTLE_ENDIAN

	#if defined(_MSC_VER)
	// MSVC6 is version 12.00, MSVC7.0 is version 13.00, MSVC7.1 is version 13.10,
	// MSVC8.0 is version 14.00, and MSVC9.0 is version 15.00.  Currently, only
	// version 9.0 or later are supported.
	#if _MSC_VER < 1400
	#error MSVC 8.0 or later is required
	#elif _MSC_VER < 1500
	#define ZEL_USING_VC80
	#else
	#define ZEL_USING_VC90
	#endif

// Disable the Microsoft warnings about not using the secure functions.
	#pragma warning(disable : 4996)

		#if _MSC_VER < 1600
			// Support for standard integer types.  This is only a small part of what
			// stdint.h provides on Unix platforms.
			#include <climits>

			typedef __int8              int8_t;
			typedef __int16             int16_t;
			typedef __int32             int32_t;
			typedef __int64             int64_t;
			typedef unsigned __int8     uint8_t;
			typedef unsigned __int16    uint16_t;
			typedef unsigned __int32    uint32_t;
			typedef unsigned __int64    uint64_t;

			#define INT8_MIN            _I8_MIN
			#define INT8_MAX            _I8_MAX
			#define INT16_MIN           _I16_MIN
			#define INT16_MAX           _I16_MAX
			#define INT32_MIN           _I32_MIN
			#define INT32_MAX           _I32_MAX
			#define INT64_MIN           _I64_MIN
			#define INT64_MAX           _I64_MAX
			#define UINT8_MAX           _UI8_MAX
			#define UINT16_MAX          _UI16_MAX
			#define UINT32_MAX          _UI32_MAX
			#define UINT64_MAX          _UI64_MAX
		#else
			// from MSVC 2010 stdint is included
			#include <cstdint>

		#endif //_MSC_VER < 1600
	#endif

#endif
//----------------------------------------------------------------------------
// Macintosh OS X platform
// Note that with the use of intel processor by apple, the big endian model
// is currently for some consoles and cell phones (powerPC)
//----------------------------------------------------------------------------
#if defined(__APPLE__)

	#if defined(__BIG_ENDIAN__)
	#define ZEL_BIG_ENDIAN
	#else
	#define ZEL_LITTLE_ENDIAN
	#endif

	#define ZEL_PLATFORM_APPLE

#endif
//----------------------------------------------------------------------------
// PC Linux platform
//----------------------------------------------------------------------------
#if !defined(__LINUX__) && defined(__linux__)
	// Apparently, many PC Linux flavors define __linux__, but we have used
	// __LINUX__.  To avoid breaking code by replacing __LINUX__ by __linux__,
	// we will just define __LINUX__.
	#define __LINUX__
	#endif
	#if defined(__LINUX__)

	// Support for standard integer types.
	#include <inttypes.h>

	#define ZEL_LITTLE_ENDIAN

	#define ZEL_PLATFORM_LINUX

#endif
//----------------------------------------------------------------------------


// Common standard library headers.
#include <cassert>
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <fstream>
#include <sstream>

// Common STL headers.
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

//Common boost headers
#include <boost/ptr_container/ptr_map.hpp>
#include <boost/unordered_map.hpp>
#include <boost/filesystem.hpp>
                        
// Opengl headers for linux
#if defined(__LINUX__)
        #include <GL/glew.h>
        #include <GL/gl.h>
#endif
                        
//Visual Leak Detector
//#include "VLD.h"

//Core appender for GLOG
const std::string CORE_APPENDER("[CORE]");

// Avoid warnings about unused variables.  This is designed for variables
// that are exposed in debug configurations but are hidden in release
// configurations.
#define ZEL_UNUSED_VAR(variable) (void)variable

#ifdef _DEBUG
	#ifdef _WIN32 
		//#define LPE_CHECK_MEMORY_LEAKS_
		#ifdef LPE_CHECK_MEMORY_LEAKS_
			#include "vld.h"
			//#pragma comment(lib, "VLD\\lib\\Win32\\vld.lib")
		#endif

		//#define USE_ZEL_ASSERTIONS
		#ifdef USE_ZEL_ASSERTIONS
			//#define ZEL_USE_ASSERT_WRITE_TO_OUTPUT_WINDOW
			#define ZEL_USE_ASSERT_WRITE_TO_MESSAGE_BOX
		#endif //USE_ZEL_ASSERTIONS
	#endif //_WIN32
#endif //_DEBUG

#endif //_ZELESTE3D_CORE_ZELESTECORELIB_H_
